<template>
  <div>
    <van-cell-group>
      <van-field
        v-model="myForm.phone"
        v-validate="'required|mobile'"
        name="phone"
        :error-message="errors.first('phone')"
        :error="errors.has('phone')"
        label="联系人电话"
        placeholder="请输入手机号码"
      />
      <van-button type="primary" @click="valid">点击验证</van-button>
    </van-cell-group>
  </div>
</template>
<script>
export default {
  data() {
    return {
      myForm: {
        username: "",
        phone: ""
      }
    };
  },
  methods: {
    valid() {
      this.$validator.validateAll().then(result => {
        if (result) {
         this.$toast('验证成功')
        }else{
         this.$toast('验证失败')
        }
      });
    }
  }
};
</script>
<style scoped lang="less">
</style>